//
//  StwxCommentItemViewModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/10/24.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "StwxCommentItemViewModel.h"

#import "TransmitListData.h"

@interface StwxCommentItemViewModel ()

/// 商品模型
//@property (nonatomic, readwrite, strong) EnterpriseInfoData* epInfoData;

@property (nonatomic, strong) id data;

@property (nonatomic, copy) NSString* name;
@property (nonatomic, copy) NSString* content;
@property (nonatomic, copy) NSString* date;
@property (nonatomic, copy) NSString* imgurl;

@end

@implementation StwxCommentItemViewModel

- (instancetype)initWithData:(NSString *)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        //        _epInfoData = data;
        
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        @weakify(self);
        [RACObserve(self, data) subscribeNext:^(id x)
        {
            @strongify(self);
            
            [self build];
        }];
    }
    
    return self;
}

- (void)resetData:(id)data
{
    self.data = data;
}

- (void)build
{
    TransmitListData* tListData = (TransmitListData*)self.data;
    
    self.name = tListData.user.wxNickName;
    self.content = tListData.content;
    self.date = tListData.addTime;
    self.imgurl = tListData.user.wxHeadImg;
}

@end
